package gamesdk.framework.impl {
	import gamesdk.framework.api.ILog;
	import gamesdk.framework.api.ILogManager;
	
	/**
	 * ...
	 * @author hanxianming
	 */
	public class LogManager implements ILogManager {
		private var _logs:Vector.<ILog>;
		
		public function LogManager() {
			init();
		}
		
		private function init():void {
			_logs = new Vector.<ILog>();
		}
		
		public function addLog(log:ILog):ILogManager {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				if (_logs[i] == log) {
					return this;
				}
			}
			_logs[len] = log;
			return this;
		}
		
		public function removeLog(log:ILog):ILogManager {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				if (_logs[i] == log) {
					_logs.splice(i, 1);
					break;
				}
			}
			return this;
		}
		
		public function info(... args):void {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				_logs[i].info(args);
			}
		}
		
		public function echo(... args):void {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				_logs[i].echo(args);
			}
		}
		
		public function debug(... args):void {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				_logs[i].debug(args);
			}
		}
		
		public function error(... args):void {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				_logs[i].error(args);
			}
		}
		
		public function warn(... args):void {
			const len:int = _logs.length;
			var i:int;
			for (i = 0; i < len; i++) {
				_logs[i].warn(args);
			}
		}
	}
}